<?php
// +----------------------------------------------------------------------
// | 有理想的地方，地狱都是天堂。
// +----------------------------------------------------------------------
// | Copyright @ df81.com 版权所有
// +----------------------------------------------------------------------
// | 作者: 南国老符 邮箱：1062129401@qq.com
// +----------------------------------------------------------------------

namespace app\admin\controller;
use think\facade\Lang;
use think\facade\Db;
use think\facade\View;

class Login {
    public function index(){
        // 判断缓存目录runtime是否可写
        $runtimePath = app()->getRootPath().'runtime';
        if(isWritable($runtimePath) == false){
            $error_tips = $runtimePath.'<br>'.lang('c_file_cannot_write');
            return json($error_tips);
        }

        //加载默认语言
        Lang::load(app()->getAppPath().'lang'.DS.config('lang.default_lang').'.php');
        //登陆欢迎词
        $helloWords = explode("**",lang('v_helloWords'));
        $helloChosen = $helloWords[mt_rand(0,(count($helloWords)-1))];
        View::assign('helloChosen', $helloChosen);
        //判断春夏秋冬显示背景
        $month=date("n");
        $month = ceil($month/3);
        switch ($month) {
            case 1:
                $season="spring";
                break;
            case 2:
                $season="summer";
                break;
            case 3:
                $season="autumn";
                break;    
            default:
                $season="winter";
                break;
        }
        View::assign('season', $season);
        //登录语言选择
        View::assign('langlist', Db::name('Language')->order('sequence desc')->limit(100)->select());
        if(!function_exists('curl_init')){
            echo 'curl function can not be used';die;
        }
        //判断是否显示验证码
        $showhide ='';
        if(!session('?loginfail')) $showhide ='none';
        View::assign('showhide',$showhide);

        return view();
    }
}